#include <iostream>
using namespace std;

void displayPoints(double points[][2], int numberOfRows)
{
  for (int i = 0; i < numberOfRows; i++)
    cout << "(" << points[i][0] << ", " << points[i][1] << ") ";

  cout << endl;
}

bool sameLine(double points[][2], int numberOfRows)
{
  if (numberOfRows < 2) return true;

  double slope = (points[0][0] - points[1][0]) /
    (points[0][1] - points[1][1]);
  for (int i = 3; i < numberOfRows; i++)
  {
    double slope1 = (points[i][0] - points[1][0]) /
      (points[i][1] - points[1][1]);

    if (slope != slope1) return false;
  }

  return true;
}

int main()
{
  double set1[][2]  = {{1, 1}, {2, 2}, {3, 3}, {4, 4}};
  double set2[][2]  = {{0, 1}, {1, 2}, {4, 5}, {5, 6}};
  double set3[][2]  = {{0, 1}, {1, 2}, {4, 5}, {4.5, 4}};

  displayPoints(set1, 4);
  cout << "same line? " << sameLine(set1, 4) << endl;

  displayPoints(set2, 4);
  cout << "same line? " << sameLine(set2, 4) << endl;

  displayPoints(set3, 4);
  cout << "same line? " << sameLine(set3, 4) << endl;

  return 0;
}
